package arduinoInterface;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;


public class SerialWriter extends Thread
    {	
		OutputStream outs;
		ByteArrayOutputStream out;
        
        public SerialWriter ( ByteArrayOutputStream out, OutputStream outs)
        {
            this.out = out;
            this.outs=outs;
        }
        
        public void run ()
        {
            
        	
			while ( ( this.out.size()) > -1 )
			{
			    try {
			    	
			    	while(true){
			    		
					this.out.writeTo(outs);
					this.out.reset();
					sleep(100);
			    	}
					
					
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}            
        }
    }
